package com.example.day3mvp.mvp.model;

import android.util.Log;
import android.widget.Toast;

import com.example.day3mvp.mvp.contrat.LoginContrat;
import com.example.mylibrary.CallBack.MyCallBack;
import com.example.mylibrary.mvp.model.BaseModel;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import java.util.HashMap;
public class LoginModel extends BaseModel implements LoginContrat.LoginModel {

     //网络请求
    @Override
    public void requestLogin(String username, String pwd, final MyCallBack myCallBack) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("username",username);
        hashMap.put("password",pwd);
        OkGo.<String>post("https://www.wanandroid.com/user/login").params(hashMap).
        execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                String body = response.body();
                myCallBack.Ok(body);

            }

            @Override
            public void onError(Response<String> response) {
                super.onError(response);
            }
        });
    }
}
